package com.qf.medicaldoctoradmin.illnesscare.collection.controller;

import com.qf.common.common.R;
import com.qf.common.entity.IllnessCare;
import com.qf.medicaldoctoradmin.illnesscare.collection.service.IllnessCareCollectService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
@CrossOrigin
@RequestMapping("/illnessCare/collection")
@Api(tags = "慢病护理收藏文章API")
public class IllnessCareCollectController {
    @Resource
    private IllnessCareCollectService illnessCareCollectService;

    @GetMapping("/collect")
    @ApiOperation(value = "文章收藏", notes = "根据文章id去收藏文章")
    public R collect(Integer careArticleId) {
        illnessCareCollectService.collect(careArticleId);
        return R.ok("收藏成功");
    }

    @ApiOperation(value = "查看用户收藏的文章", notes = "根据用户id来查看收藏的文章")
    @GetMapping("/select")
    public R selectById(Integer userId) {
        List<IllnessCare> illnessCareCollects = illnessCareCollectService.selectById(userId);
        return R.ok(illnessCareCollects);
    }
}
